package com.kundi.dooradmin.mapper;

import com.kundi.dooradmin.entity.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * Author 赵恒
 * Date 2020/6/22
 */
public interface ProductMapper extends Mapper<Product> {
    @Delete("delete from tb_product where id = #{id}")
    Integer deleteById(@Param("id") Integer id);

    @Select("select id, title_zh as titleZh, title_en as titleEn, content, item_index as itemIndex from tb_product where id != 100 order by item_index")
    List<Product> getAll();

    @Select("select id, title_zh as titleZh, title_en as titleEn, content, item_index as itemIndex from tb_product where id = #{id}")
    Product getProductById(@Param("id") Integer id);

    @Select("select id, title_zh as titleZh, title_en as titleEn, content, item_index as itemIndex from tb_product where title_en in (\"QuantyMine\", \"QuantyEngine\", \"QuantyUrban\")")
    List<Product> getFirstProduct();
}
